home *** CD-ROM | disk | FTP | other *** search
- // Sample Dialog Plug In
- //
- // © 1996 Now Software, Inc
- // written by: hac
-
- #include "Main.h"
- #include <Quickdraw.h>
-
- #define kMyPlugInStrings 128
- #define kMenuTextIndex 1
- #define kMyPlugInDialog 128
-
- #define kOkay 1
- #define kCancel 2
-
- pascal void main(PlugInInformation *plugInInformation)
- {
- plugInInformation->version = kPlugInInformationVersionOne;
- plugInInformation->plugInType = kDialogPlugIn;
- plugInInformation->PrepareMenu = &PrepareMenu;
- plugInInformation->HandleMenuItemSelected = &HandleMenuItemSelected;
- }
-
- pascal void PrepareMenu(InstantAccessInformation *information, short asPreview)
- {
- MenuItemInformation menuItem;
-
- // add a divider above
- menuItem.version = kMenuItemInformationVersionOne;
- menuItem.classification = kMiscellaneousClassification;
- menuItem.type = kDividerMenuItemType;
- menuItem.id = 1;
- menuItem.enabled = true;
- menuItem.style = 0;
- menuItem.mark = 0;
- menuItem.hasSubMenu = FALSE;
- menuItem.subMenu = nil;
- menuItem.refCon = 0;
- menuItem.owningPlugInType = kDialogPlugIn;
-
- (*information->AddMenuItem)(&menuItem);
-
-
-
- BlockMove("\pSample Plug In Dialog", menuItem.text, kMenuItemTextSize);
-
- menuItem.type = kTextMenuItemType;
- menuItem.id = 2;
- menuItem.enabled = true;
-
- (*information->AddMenuItem)(&menuItem);
-
- BlockMove("\pSample Plug In Dialog", menuItem.text, kMenuItemTextSize);
-
- menuItem.type = kDividerMenuItemType;
- menuItem.id = 3;
- menuItem.enabled = true;
-
- (*information->AddMenuItem)(&menuItem);
-
- }
-
- pascal void CleanUpAfterMenuSelect(InstantAccessInformation *information, short asPreview)
- {
- //hmmmm....
- }
-
- pascal void HandleMenuItemSelected(InstantAccessInformation *information, MenuItemInformation *menuItem)
- {
- GrafPtr currPort = nil;
- DialogPtr myPlugInDialog = nil;
- short itemHit;
- FSSpec spec;
- short curResFile;
- short refNum = -1;
- Boolean finished = FALSE;
-
- curResFile = CurResFile();
-
- (*information->GetPlugInFileSpec)(kDialogPlugIn, &spec);
-
- refNum = FSpOpenResFile(&spec, fsRdWrPerm);
- if (refNum == -1) {
- goto error;
- }
-
- myPlugInDialog = GetNewDialog(kMyPlugInDialog, nil, (WindowPtr)-1);
-
- if (myPlugInDialog == nil) {
- goto error;
- }
-
- GetPort(&currPort);
- SetPort(myPlugInDialog);
-
-
- do {
- ModalDialog(nil, &itemHit);
-
- switch (itemHit) {
-
- case kOkay:
- finished = TRUE;
- break;
-
- case kCancel:
- finished = TRUE;
- break;
-
- otherwise:;
-
- }
-
- } while ( !finished);
-
-
-
- error:
- if (myPlugInDialog != nil) {
- DisposDialog(myPlugInDialog);
- }
-
- if (currPort != nil) {
- SetPort(currPort);
- }
-
- if (refNum != -1) {
- CloseResFile(refNum);
- }
-
- UseResFile(curResFile);
- }
-